package org.jeecg.modules.bim.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.bim.entity.BimAreas;
import org.jeecg.modules.bim.service.IBimAreasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/bim")
@Api(tags = "bim区域数据")
public class BimAreasController {

    @Autowired
    private IBimAreasService bimAreasService;



    /**
     * 设备数据添加
     *
     * @param projectInfoId
     * @return
     */
    @ApiOperation(value = "区域数据列表-查询", notes = "区域数据列表-查询")
    @GetMapping(value = "areas/query")
    public Result<List<BimAreas>> queryDevs(@RequestParam @ApiParam("工程管理自增id") Integer projectInfoId) {
        List<BimAreas> bimAreas = bimAreasService.queryAreas(projectInfoId, null);
        return Result.OK(bimAreas);
    }

    /**
     * 区域数据添加
     *
     * @param bimAreas
     * @return
     */
    @AutoLog(value = "区域数据添加")
    @ApiOperation(value = "区域数据添加", notes = "区域数据添加")
    @PostMapping(value = "areas/add")
    public Result<?> add(@RequestBody BimAreas bimAreas) {
        return Result.OK(bimAreasService.addBimAreas(bimAreas));
    }

    /**
     * 区域数据添加
     *
     * @param id
     * @return
     */
    @AutoLog(value = "区域数据删除")
    @ApiOperation(value = "区域数据删除", notes = "区域数据删除")
    @DeleteMapping(value = "areas/delete")
    public Result<String> delete(@RequestParam Long id) {
        bimAreasService.removeById(id);
        return Result.OK("删除成功！");
    }

    /**
     * 区域数据添加
     *
     * @param bimAreas
     * @return
     */
    @AutoLog(value = "区域数据编辑")
    @ApiOperation(value = "区域数据编辑", notes = "区域数据编辑")
    @PostMapping(value = "areas/edit")
    public Result<?> editAreas(@RequestBody BimAreas bimAreas) {
        bimAreasService.updateById(bimAreas);
        return Result.OK(bimAreasService.getById(bimAreas.getId()));
    }

}
